﻿<template>
  <div class="coop">
    <header_ title="联系我们" :pathName="this.$store.state" background='#ffffff' color='#000000' image_='0' size='4.8vw' />
    <div class="coop_choice">
      <!-- <p>请选择合作类型</p>
      <select v-model="cooptype">
        <option
          style="width: 80vw"
          v-for="(item, index) in selList"
          :value="item.value"
          :key="index"
        >
          {{ item.name }}
        </option>
      </select> -->
      <p>联系人姓名:</p>
      <input type="text" v-model="coopname" placeholder="请填写" />
      <p>联系人微信：</p>
      <input type="text" v-model="coopvx" placeholder="请填写" />
      <!-- <p>请在此留言</p> -->
      <textarea
        v-model="coopjianyi"
        placeholder="有什么想说的都可以写在这里…"
      ></textarea>
    </div>
    <div class="coop_sub" @click="subClick">提交</div>
    <p>*提交后工作人员会在1个工作日内联系你</p>
  </div>
</template>

<script>
 import header_ from '../../components/header_'
import md5 from "js-md5";
import qs from "qs";
import { Toast } from "vant";
export default {
  data() {
    return {
      selList: [
        {
          name: "公会合作",
          value: 1,
        },
        {
          name: "广告合作",
          value: 2,
        },
        {
          name: "内容合作",
          value: 3,
        },
        {
          name: "其他咨询",
          value: 4,
        },
      ],
      type:'1',
      cooptype: "",
      coopname: "",
      coopvx: "",
      coopjianyi: "",
    };
  },
      components: {
      header_
    },
  created() {
    let url = location.href;
    this.cooptype = url.split("?")[1].split("=")[1];
  },
  methods: {
    subClick() {
      if (!this.coopname) {
        return Toast("联系人姓名不能为空");
      }
      if (!this.coopvx) {
        return Toast("联系人微信不能为空");
      }
      let timestamp = (Date.parse(new Date()) / 1000).toString();
      let arys = {
        userId: window.user_id,
        token: window.userToken,
        type: this.type,
        realname: this.coopname,
        wechat: this.coopvx,
        message: this.coopjianyi,
        time: timestamp,
      };
      let _token = this.$.encryption(arys);
      // let _token =
      //   "wechat=" +
      //   this.coopvx +
      //   "&userId=" +
      //   window.user_id +
      //   "&type=" +
      //   this.cooptype +
      //   "&token=" +
      //   window.userToken +
      //   "&time=" +
      //   timestamp +
      //   "&realname=" +
      //   this.coopname +
      //   "&message=" +
      //   this.coopjianyi +
      //   "&wPQvCAOU$lbIyg9o2wVg0Dt1k^zy&SaX";
      let params = {
        userId: window.user_id,
        token: window.userToken,
        type: this.type,
        realname: this.coopname,
        wechat: this.coopvx,
        message: this.coopjianyi,
        time: timestamp,
        sign: md5(_token),
      };
      this.$axios
        .post("/index/cooperate", qs.stringify(params))
        .then((res) => {
          console.log(res.data.result);
          Toast(res.data.text);
        })
        .catch((err) => {
          console.log(err);
        });
    },
  },
};
</script>
<style>
.coop {
  width: 90.4vw;
  height: 100vh;
  overflow: auto;
  padding: 0 4.8vw;
}
.coop_choice {
  width: 90.4vw;
  margin-top: 22.6vw;
}
.coop_choice > p {
  line-height: 12.6vw;
  font-size: 3.4vw;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #333333;
}
.coop_choice > select {
  height: 11.11vw;
  border-radius: 1.45vw;
  border: 1px solid #e6e6e6;
  box-sizing: border-box;
  padding: 0 3.9vw;
  width: 90.4vw;
  font-size: 3.4vw;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
}
.coop_choice > input {
  padding: 0 3.9vw;
  width: 90.4vw;
  height: 11.11vw;
  border-radius: 1.45vw;
  border: 1px solid #e6e6e6;
  box-sizing: border-box;
  font-size: 3.4vw;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  margin-bottom: 10px;
}
.coop_choice > textarea {
  height: 39.1vw;
  padding: 3.1vw 3.9vw;
  width: 90.4vw;
  border-radius: 1.45vw;
  border: 1px solid #e6e6e6;
  box-sizing: border-box;
  font-size: 3.4vw;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
}
.coop_sub {
  width: 90.4vw;
  height: 12.8vw;
  background: #0091ff;
  border-radius: 2.4vw;
  margin-top: 9.7vw;
  font-size: 3.9vw;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: #ffffff;
  text-align: center;
  line-height: 12.8vw;
}
.coop > p {
  margin-top: 2.9vw;
  font-size: 2.9vw;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #303030;
}
</style>